<?php
	class Template extends CI_Model{
		
		public function __construct(){
			parent::__construct();
		}
		
		public function header(){
			$str ='
			  	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
				<html xmlns="http://www.w3.org/1999/xhtml">
				<head>
				<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
				<link rel="stylesheet" type="text/css" href="'.base_url().'css/theme.css" media="screen" />
				<link rel="stylesheet" type="text/css" href="'.base_url().'css/login.css" media="screen" />
				<link rel="stylesheet" type="text/css" href="'.base_url().'fancybox/jquery.fancybox-1.3.0_back.css" media="screen" />
				<script type="text/javascript" src="'.base_url().'js/jquery-1.4.1.min.js"></script>
				<script type="text/javascript" src="'.base_url().'tiny_mce/tiny_mce.js"></script>
				<script src="'.base_url().'tiny_mce/plugins/tinybrowser/tb_tinymce.js.php" type="text/javascript"></script>		
				<script type="text/javascript" src="'.base_url().'fancybox/jquery.fancybox-1.3.0.pack.js"></script>
				<script type="text/javascript" language="javascript">
						$(document).ready(function() {
				//				$.noConflict();					 									
								jQuery("a.galleryLightbox").fancybox({
									\'titleShow\'     : true,
									\'transitionIn\'	: \'elastic\',
									\'transitionOut\'	: \'elastic\',
									 height: 600,
       								 width: 1000		
								});
				});
								
				
					    function getcate(strURL)
					    {     
						alert(strURL);    
					     var req = getXMLHTTP(); // fuction to get xmlhttp object
					     if (req)
					     {
					      req.onreadystatechange = function()
					     {
					      if (req.readyState == 4) { //data is retrieved from server
					       if (req.status == 200) { // which reprents ok status                    
					         document.getElementById(\'citydiv\').innerHTML=req.responseText;
					      }
					      else
					      { 
					         alert("There was a problem while using XMLHTTP:\n");
					      }
					      }            
					      }        
					    req.open("GET", strURL, true); //open url using get method
					    req.send(null);
					     }
					    }
				</script>
				<title>Administrator</title>
				</head>
				
				<body>
				<div id="container"> 
				  <div class="radius-bottom" id="adminbar">
				    <div id="logo">Administrator</div>
				    <div id="detail-user">
				      <p>Hi! '.$this->session->userdata('sess_hname').'  '.$this->session->userdata("sess_customer_name").'</p>
				     <!-- <a href="#" class="color-green">Visit website</a> | -->
				      <a href="'.base_url().'manage_user/profile" class="color-orang">Change Password</a> | 
				      <a href="'.base_url().'apanel/logout" class="color-red">Logout</a>
				      </p>
				    </div>
				    <div style="clear:both"></div>
				  </div>
			';
			return $str;
		}
		
		public function footer(){
			$str ='
				  <div id="footer"class="radius-bottom"> ';
			$str .= date("Y");
			$str .=' © eShineTV </div>
				  </div>
				</body>
				</html>
			';
			return $str;
		}
		
		public function menu($mark="",$active=""){
			$m1="";$m2="";$m3="";$m4="";$m5="";$m6="";$m7="";$m8="";$m9="";$m10="";$m12="";
			$s1="";$s2="";$s3="";$s4="";$s5="";$s6="";$s7="";$s8="";$s9="";$s10="";$s12="";
			switch ($mark){
				case 1: $m1='class="active submenu-active" '; $s1='<span class="submenu-arrow"></span>'; break;
				case 2: $m2='class="active submenu-active"'; $s2='<span class="submenu-arrow"></span>'; break;
				case 3: $m3='class="active submenu-active"'; $s3='<span class="submenu-arrow"></span>'; break;
				case 4: $m4='class="active submenu-active"'; $s4='<span class="submenu-arrow"></span>'; break;
				case 5: $m5='class="active submenu-active"'; $s5='<span class="submenu-arrow"></span>'; break;
				case 6: $m6='class="active submenu-active"'; $s6='<span class="submenu-arrow"></span>'; break;
				case 7: $m7='class="active submenu-active"'; $s7='<span class="submenu-arrow"></span>'; break;
				case 8: $m8='class="active submenu-active"'; $s8='<span class="submenu-arrow"></span>'; break;
				case 9: $m9='class="active submenu-active"'; $s9='<span class="submenu-arrow"></span>'; break;
				case 10: $m10='class="active submenu-active"'; $s10='<span class="submenu-arrow"></span>'; break;
				case 11: $m11='class="active submenu-active"'; $s11='<span class="submenu-arrow"></span>'; break;
				case 12: $m12='class="active submenu-active"'; $s12='<span class="submenu-arrow"></span>'; break;
			}
		 $strm ='<div id="menu" class="radius-top clearfix">
					    <ul id="main-menu" >';
		 if($this->session->userdata('sess_access')== 'superadmin' || $this->session->userdata('sess_access') == 'admin'){
			 $strm .='<li><a href="'.base_url().'apanel/dashboard" '.$m1.'><img src="'.base_url().'images/icon/home.png"/>
						      <span>Dashboard</span></a></li>';
		 }
		 if($this->session->userdata('sess_access')== 'superadmin'){
			$strm .='<li><a href="'.base_url().'manage_channel" '.$m4.'><img src="'.base_url().'images/icon/tv.png" />
						      <span>TV</span>'.$s4.'</a></li>';
			$strm .='<li><a href="'.base_url().'manage_card" '.$m5.'><img src="'.base_url().'images/icon/card.png" />
						      <span>Card</span>'.$s5.'</a></li>'; 
			$strm .='<li><a href="'.base_url().'manage_customer" '.$m7.'><img src="'.base_url().'images/icon/customer.png" />
						      <span>Customer</span>'.$s7.'</a></li>';
						  
		}
		if($this->session->userdata('sess_access')== 'superadmin' || $this->session->userdata('sess_access') == 'admin'){
			$strm .='<li><a href="'.base_url().'manage_info/customer_info" '.$m2.'><img src="'.base_url().'images/icon/info.png" />
			<span>Info</span>'.$s2.'</a></li>';
		
			$strm .='<li><a href="'.base_url().'manage_news" '.$m3.'><img src="'.base_url().'images/icon/news.png" />
						      <span>News/Activity</span>'.$s3.'</a></li>';
			if($this->session->userdata('sess_access')== 'superadmin' || $this->session->userdata('sess_access') == 'admin')
			{
				$strm .='<li><a href="'.base_url().'manage_product" '.$m6.'><img src="'.base_url().'images/icon/products.png" />
						      <span>Product</span>'.$s6.'</a></li>';
			}
		}
		if($this->session->userdata('sess_access')== 'superadmin'){
			$strm .='<li><a href="'.base_url().'manage_user/user_list" '.$m9.'><img src="'.base_url().'images/icon/user.png" />
						      <span>User</span>'.$s9.'</a></li>';
							  
			}
			
		if($this->session->userdata('sess_customer_name') =='huawei' || $this->session->userdata('sess_access')== 'superadmin'){
				$strm .='<li><a href="'.base_url().'manage_message" '.$m12.'><img src="'.base_url().'images/icon/msg.png" />
			<span>Message</span>'.$s12.'</a></li>';
		}
		$strm .='</ul>
					    '.$this->submenu($mark,$active).'
  					</div>';
			return $strm;
		}
		
		public function submenu($sub="",$active=""){
			$str = "";$a1="";$a2="";$a3="";$a4="";$a5="";$a6="";$a7="";$a8="";$a9="";$a10="";$a11="";
			if($active =="" || $active == 1) $a1= 'class="active"';
			else if($active == 2) $a2= 'class="active"';
			else if($active == 3) $a3 = 'class="active"';
			else if($active == 4) $a4 = 'class="active"';
			else if($active == 5) $a5 = 'class="active"';
			else if($active == 6) $a6 = 'class="active"';
			else if($active == 7) $a7 = 'class="active"';
			else if($active == 8) $a8 = 'class="active"';
			else if($active == 9) $a9 = 'class="active"';
			else if($active == 10) $a10 = 'class="active"';
			else if($active == 11) $a11 = 'class="active"';
			else if($active == 12) $a12 = 'class="active"';
			switch ($sub){
				case 2: $str='
					<ul id="sub-menu" class="clearfix">	      
				      <li><a href="'.base_url().'manage_info/customer_info" '.$a1.'>Partner Info</a></li>';
						if($this->session->userdata('sess_access')== 'superadmin' || 
								$this->session->userdata('sess_customer_name') =='chalachol' ||   
								 $this->session->userdata('sess_hname') =='hotpot' || 
								$this->session->userdata('sess_customer_name') =='huawei'){
							   $str .='<li><a href="'.base_url().'manage_branch/cate_list" '.$a2.'>Branch Category</a></li>';
						      $str .='<li><a href="'.base_url().'manage_branch/branch_list" '.$a3.'>Branch</a></li>';
						}
						if($this->session->userdata('sess_access')== 'superadmin' ||
						 $this->session->userdata('sess_customer_name') =='huawei' || $this->session->userdata('sess_customer_name') =='sherman'){
								$str .='<li><a href="'.base_url().'manage_banner/banner_list" '.$a4.'>Banner</a></li>';
								}
				    $str .='</ul>';
				break;
				case 3: $str='
					 	<ul id="sub-menu" class="clearfix">
				      	<li><a href="'.base_url().'manage_news/news_list" '.$a2.'>News/Activity List</a></li>';
						if($this->session->userdata('sess_customer_name') !='sherman'){
				      	$str .='<li><a href="'.base_url().'manage_vdo/vdo_list" '.$a3.'>Vdo List</a></li>
				      	<li><a href="'.base_url().'manage_gallery/gallery_list" '.$a4.'>Gallery List</a></li>';
						}
					 	$str.='</ul>';
				break;
				case 4: $str='
					<ul id="sub-menu" class="clearfix">
      					<li><a href="'.base_url().'manage_channel/channellist" '.$a1.'>TV List</a></li>
    				</ul>
				';
				break;
				case 5: $str='
				<ul id="sub-menu" class="clearfix">
      				<li><a href="'.base_url().'manage_card/card_list" '.$a1.'>Card list</a></li>
      				<li><a href="'.base_url().'manage_card/card_add" '.$a2.'>Add card</a></li>
      				<!--<li><a href="'.base_url().'manage_card/" '.$a3.'>Member List</a></li>-->
    			</ul>
				';
				break;
				case 6: $str='
				<ul id="sub-menu" class="clearfix">
				  <li><a href="'.base_url().'manage_product/cate_list/0" '.$a1.'>Manage Category</a></li>
				  <li><a href="'.base_url().'manage_product/product_list" '.$a2.'>Manage Products</a></li>';
				      
				if($this->session->userdata('sess_access')== 'superadmin'||$this->session->userdata('sess_customer_name') =='sherman'){
				    $str .= '<li><a href="'.base_url().'manage_gift/gift_list" '.$a3.'>Gift</a></li>';
					$str .='<li><a href="'.base_url().'manage_gift/member_gift" '.$a4.'>Member Gift</a></li>';
					$str .='<li><a href="'.base_url().'manage_gift/code_gift" '.$a5.'>Gift Code</a></li>';
					
					}
					if($this->session->userdata('sess_customer_name') =='huawei' || $this->session->userdata('sess_access')== 'superadmin'){
						$str .='<li><a href="'.base_url().'manage_campaign/campaign_list" '.$a8.'>Campaign</a></li>';
				      	$str .='<li><a href="'.base_url().'manage_warranty/war_list" '.$a6.'>Warranty</a></li>';
						$str .='<li><a href="'.base_url().'manage_tracking/track_list" '.$a7.'>Warranty Tracking</a></li>';
						$str .='<li><a href="'.base_url().'manage_certificate/cer_list" '.$a9.'>Certificate</a></li>';
						}
				     
    			$str.='</ul>';
				break;
				case 7: $str='
				<ul id="sub-menu" class="clearfix">
				<li><a href="'.base_url().'manage_customer/customer_list" '.$a1.'>Customer List</a></li>
				</ul>
				';
				break;
				case 8: $str='
				<ul id="sub-menu" class="clearfix">
				<li><a href="'.base_url().'manage_order/order_list" '.$a1.'>Service Order List</a></li>
				<li><a href="'.base_url().'manage_order/shoping_list" '.$a2.'>Shoping Cart List</a></li>
				</ul>
				';
				break;
				case 9: $str='
				<ul id="sub-menu" class="clearfix">
				<li><a href="'.base_url().'manage_user/user_list" '.$a1.'>User List</a></li>
				<!--<li><a href="'.base_url().'manage_user/user_access" '.$a2.'>User access</a></li>-->
				</ul>
				';
				break;
				case 10: $str='
				<ul id="sub-menu" class="clearfix">
				<li><a href="'.base_url().'manage_hotel/hotel_info" '.$a1.'>Setting</a></li>
				</ul>
				';
				case 12: $str='
				<ul id="sub-menu" class="clearfix">
					<li><a href="'.base_url().'manage_message/message_list" '.$a1.'>Message</a></li>
				</ul>
				';
				break;
				default:
			}
			return $str;
		}
		
		public function tinymce(){
			// Default skin
			$str  ='
			<script>
			tinyMCE.init({
				// General options
				mode : "exact",
				elements : "elm1,elm2,elm3",
				theme : "advanced",
				plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups,autosave",
			
				// Theme options
				theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
				theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
				theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
				theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft",
				theme_advanced_toolbar_location : "top",
				theme_advanced_toolbar_align : "left",
				theme_advanced_statusbar_location : "bottom",
				theme_advanced_resizing : true,
				file_browser_callback : "tinyBrowser"
				// Replace values for the template plugin
			
			});
			
			</script>';
			return $str;
		}
	}
?>